package upgrade

import (
	"context"

	"github.com/sagoo-cloud/sagooiot/api/v1/upgrade"
	"github.com/sagoo-cloud/sagooiot/internal/service"
)

var UpgradeHttp = cUpgradeHttp{}

type cUpgradeHttp struct{}

// 获取升级信息
func (c *cUpgradeHttp) GetUpgradInfo(ctx context.Context, req *upgrade.GetOtaInfoReq) (res *upgrade.GetOtaInfoRes, err error) {
	res, err = service.UpgradeHttp().GetUpgradeInfo(ctx, req)
	return
}

// WriteUpgradeInfo 更新升级进度
func (c *cUpgradeHttp) WriteUpgradeInfo(ctx context.Context, req *upgrade.WriteOtaInfoReq) (res *upgrade.WriteOtaInfoRes, err error) {
	err = service.UpgradeHttp().WriteUpgradeInfo(ctx, req)
	return
}

// WriteUpgradeInfo 更新升级结果
func (c *cUpgradeHttp) WriteUpgradeResult(ctx context.Context, req *upgrade.WriteOtaResultReq) (res *upgrade.WriteOtaResultRes, err error) {
	err = service.UpgradeHttp().WriteUpgradeResult(ctx, req)
	return
}
